/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 wave_sound.h

	$Header: /resource_editor/wave_sound.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( ABSTRACT__FILE_H_INCLUDED )
#define ABSTRACT__FILE_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "counted_ptr.h"
#include "sized_int_types.h"
#include <string>

// -------------------------------------------------------------
// abstract file class wraps a system specific file functions, emulates standard c
// file access functions (fopen, fclose, fseek, fwrite, fread)
// -------------------------------------------------------------

enum t_abstract_file_state
{
		k_file_closed	= 1,
		k_file_opened	= 2
};

enum t_derived_file_systems
{
	k_standard_c_file_sys,
	k_windows_file_sys
};

class t_abstract_file : public t_counted_object
{
public:

	t_abstract_file();
	virtual ~t_abstract_file(){}

	virtual bool open( const char *filename, const char *mode ) = 0;
	virtual bool close( ) = 0;

	virtual t_int32		filesize( ) = 0;
	virtual t_int32		seek( long offset, int origin ) = 0;
	virtual t_uint32	read( void *buffer, t_uint32 size, t_uint32 count) = 0;
	virtual t_uint32	write( const void *buffer, t_uint32 size, t_uint32 count) = 0;
	virtual char* 		get_file_handle() = 0;

	bool				is_open();

protected:

	t_abstract_file_state		m_file_state;
	std::string					m_file_name;
};

inline t_abstract_file::t_abstract_file() : m_file_state ( k_file_closed ) {}

inline bool	 t_abstract_file::is_open()
{
	if (m_file_state == k_file_opened) 
		return true;

	return false;
}

typedef t_counted_ptr<t_abstract_file> t_abstract_file_ptr;

#endif // ABSTRACT__FILE_H_INCLUDED